package com.lbt.eduservice.controller;


import com.lbt.commonuntils.JwtUtils;
import com.lbt.commonuntils.R;
import com.lbt.eduservice.entity.EduComment;
import com.lbt.eduservice.entity.EduCourse;
import com.lbt.eduservice.service.EduCommentService;
import com.lbt.eduservice.service.EduCourseService;
import com.lbt.eduservice.service.EduTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 评论 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-06-09
 */
@Api(description = "评论管理")
//@CrossOrigin
@RestController
@RequestMapping("/eduservice/comment")
public class EduCommentController {
    @Autowired
    EduCommentService commentService;
    @Autowired
    EduCourseService courseService;


    @ApiOperation("增加评论")
    @PostMapping("/addCommont/{courseId}") //评论内容 我要手动加上其他信息 前端要返回 课程ID
    public R addCommont(@PathVariable String courseId,@RequestBody EduComment comment, HttpServletRequest request){
        //从request 中获取token  解析 获取 用户ID
        String userId = JwtUtils.getMemberIdByJwtToken(request);
        //从课程ID 获取信息
        EduCourse courseInfo = courseService.getById(courseId);

        //从登录用户的ID 获取信息 远程调用


        comment.setCourseId(courseId);

        comment.setMemberId(userId);
        return R.ok();
    }

    //增加评论

    //删除评论

    //修改评论


}

